package com.yu.transport.constants;

import com.sun.corba.se.impl.interceptors.PICurrent;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

/**
 * @PackageName: com.yu.transport.codec
 * @Description: 解码和编码使用的是LengthFieldBaseFrameDecoder
 * 所以应该包含魔数、长度、等等常量
 * @Version: v1.0.0
 * @Author: yuweilin
 * @Date: 15:12
 * <p>
 * Modification History:
 * Date         Author          Version            Description
 * ------------------------------------------------------------
 * 2021/1/27      yuweilin         v1.0.0               新建
 */
public class NettyConstants {
    public static final byte[] MAGIC_NUMBER = {(byte)'g', (byte)'r',(byte)'p',(byte)'c'};
    public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;

    public static final byte VERSION = 1;
    public static final int MAX_FRAME_LENGTH = 8*1024*1024;
    public static final int LENGTH_FIELD_LENGTH = 4;
    public static final int CORRECTION_VALUE = -9;
    public static final int LENGTH_OFFSET = 5;
    public static final int HEAD_LENGTH = 14;
    //messageType
    public static final byte REQUEST_TYPE = 1;
    public static final byte RESPONSE_TYPE =2;
    public static final byte HEARTBEAT_TYPE=3;
    public static final String PING = "ping";
    /**
     * Magic number. Verify RpcMessage
     */
//    public static final byte[] MAGIC_NUMBER = {(byte) 'g', (byte) 'r', (byte) 'p', (byte) 'c'};
//    public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
//    //version information
//    public static final short VERSION = 1;
//    public static final byte TOTAL_LENGTH = 16;
//    public static final byte REQUEST_TYPE = 1;
//    public static final byte RESPONSE_TYPE = 2;
//    //ping
//    public static final byte HEARTBEAT_REQUEST_TYPE = 3;
//    //pong
//    public static final byte HEARTBEAT_RESPONSE_TYPE = 4;
//    public static final int HEAD_LENGTH = 16;
//    public static final String PING = "ping";
//    public static final String PONG = "pong";
//    public static final int MAX_FRAME_LENGTH = 8 * 1024 * 1024;

}
